package com.cskaoyan.javase.oop3._2inner._3local._4life;

import com.sun.xml.internal.bind.v2.model.core.ID;

/**
 * 之所以局部内部类当中访问的局部变量必须是final
 *      这是因为局部变量和对象的生命周期有冲突
 * 
 * @since 15:47
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo {
    public static void main(String[] args) {
        Enclosed ec = new Enclosed();
        // test方法调用会返回接口IA的实现类对象
        IA ia = ec.test();
        ia.method();
    }
}
class Enclosed{
    public IA test(){
        int a = 10;
        class IAImpl implements IA{
            @Override
            public void method() {
                System.out.println(a);
                // a = 100;
            }

            public IAImpl() {
                System.out.println("hello");
            }
        }
        IAImpl ia = new IAImpl();
        ia.method();
        System.out.println(a);
        return ia;
    }
}
interface IA{
    void method();
}